<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    //双指针 不想等的 赋值num[slow+1]=num[fast] 
    //慢指针在不想等的时候再++
    function fn(num) {
        let slow = 0;
        let fast = 1;
        let n = num.length;
        while (fast < n) {
            if (num[slow] !== num[fast]) {
                num[++slow] = num[fast]
            }
            fast++
        }
        return slow + 1
    }
    fn([0, 1, 2, 2, 3, 3, 4])
</script>

</html>